
/*
 * 日历控件 Tbdcalendar
 * @Author                   透笔度（邮箱：1530341234@qq.com 个人博客：http://my.oschina.net/tbd/blog/652988）
 * @param id                 根id
 * @param opts.top           相对文本框的上偏移
 * @param opts.left          相对文本框的左偏移
 * @param opts.clickhide     选择日期后是否隐藏日历控件 默认false 不隐藏
 * @param opts.splits        格式化日期输出形式
 * @param opts.isnull        是否显示上下月份日期 true不显示 false显示
 * @param opts.ymd           指定日历初始化时所在日期月份 null默认当前月份 指定格式y/m/d
 * @param opts.hm            时、分是否显示和可用 false不可用
 * @param opts.speedmonth    是否使用月份快捷设置 默认false关闭快捷设置
 * @param opts.speedyear     是否使用年快捷设置   默认false关闭快捷设置,is:true设置开启 interval:3设置年份上下跨度
 * @version 1.2.1
 */
//日历控件 Tbdcalendar
(function(w){
    function Tbdcalendar(id,opts){//face fun
		function TBDcalendar(id,opts){//class
			//获取根部id
			this.dateid=id;
			//根时间对象
			this.dateObj = null;
			if(opts.ymd){//被设置
				this.dateObj = new Date(opts.ymd);
			}else{//默认
				this.dateObj = new Date();
			};
			//点击本月日期是否隐藏控件
			this.clickhide = opts.clickhide;
			//是否显示时、分
			this.hm = opts.hm;
			//是否快捷月份功能
			this.speedmonth = opts.speedmonth;
			//是否快捷年功能
			this.speedyear = opts.speedyear.is;
			//捷年功能跨度
			this.speedyear_interval = opts.speedyear.interval;
			//前一个时间对象
			this.prevdateObj = null;
			//后一个时间对象
			this.nextdateObj = null;
			//元素存储
			this.obody=document.body;
			this.date=document.getElementById(this.dateid);
			//可选设置
			//是否填充空白
			this.isnull=opts.isnull;
			//日期分隔符
			this.splits=opts.splits;
			//获取显示位置
			this.tl=opts.left;
			this.tt=opts.top;
			//末代元素存储
			this.box=null;
			this.omonth=null;
			this.oyear=null;
			this.con=null;
			this.prevmonth=null;
			this.nextmonth=null;
			this.prevyear=null;
			this.nextyear=null;
			this.nowtime=null;
			this.cleartime=null;
			//获取时分显示元素
			this.stime=null;
			this.htime=null;
			this.mtime=null;
			//获取快捷月份元素
			this.speedm=null;
			//获取快捷年元素
			this.speedy=null;
			//防止冲突
			var that=this;
			//方法
			this.open=function(){
				//创建结构
				this.createhtml();
				//前后时间对象设置
				this.setprevobj(this.dateObj);
				this.setnextobj(this.dateObj);
				//获取元素
				this.box=document.getElementById("tbd"+this.dateid);
				//通过class名获取
				this.omonth=this.queryclass(this.box,"tbdc_month")[0];
				this.oyear=this.queryclass(this.box,"tbdc_year")[0];
				this.con=this.queryclass(this.box,"tbdc_con")[0];
				this.prevmonth=this.queryclass(this.box,"tbdc_prevmonth")[0];
				this.nextmonth=this.queryclass(this.box,"tbdc_nextmonth")[0];
				this.prevyear=this.queryclass(this.box,"tbdc_prevyear")[0];
				this.nextyear=this.queryclass(this.box,"tbdc_nextyear")[0];
				this.nowtime=this.queryclass(this.box,"tbdc_nowtime")[0];
				this.cleartime=this.queryclass(this.box,"tbdc_cleartime")[0];
				//获取时分显示元素
				this.stime=this.queryclass(this.box,"tbdc_hm_show")[0];
				this.htime=this.queryclass(this.box,"tbdc_hm_h")[0];
				this.mtime=this.queryclass(this.box,"tbdc_hm_m")[0];
				//获取快捷月份元素
				if(this.speedmonth){
					this.speedm=this.queryclass(this.box,"tbdc_speedm")[0];
					this.speedmonthhtml();
				};
				//获取快捷年份元素
				if(this.speedyear){
					this.speedy=this.queryclass(this.box,"tbdc_speedy")[0];
					this.speedyearhtml();
				};
				//月年的显示
				this.setyearmonth(this.dateObj);
				//===================set day===============================
				//获取本月1号的周值
				var oneweek=this.oneyearoneday(this.dateObj);
				//本月总日数
				var alld=this.alldays(this.dateObj);
				//当前是几
				var nowd=this.nowday(this.dateObj);
				//初始化显示本月信息
				this.init(oneweek,alld,nowd);
				//事件监听
				this.addevent();
			};
			//前后时间对象设置
			this.setprevobj=function(dateObj){
				var ddy=((dateObj.getMonth()-1)==-1)?dateObj.getFullYear()-1:dateObj.getFullYear();
				var ddm=((dateObj.getMonth()-1)==-1)?11:dateObj.getMonth()-1;
				var ddd=dateObj.getDate();
				var prevdateObj=new Date();
				prevdateObj.setFullYear(ddy);
				prevdateObj.setMonth(ddm);
				prevdateObj.setDate(ddd);
				this.prevdateObj=prevdateObj;
			};
			this.setnextobj=function(dateObj){
				var ddy=((dateObj.getMonth()+1)==12)?dateObj.getFullYear()+1:dateObj.getFullYear();
				var ddm=((dateObj.getMonth()+1)==12)?0:dateObj.getMonth()+1;
				var ddd=dateObj.getDate();
				var nextdateObj=new Date();
				nextdateObj.setFullYear(ddy);
				nextdateObj.setMonth(ddm);
				nextdateObj.setDate(ddd);
				this.nextdateObj=nextdateObj;
			};
			//创建结构
			this.createhtml=function(){
				var ddbox=document.createElement("div");
				ddbox.id="tbd"+this.dateid;
				ddbox.className="tbdc_box";
				ddbox.style.display="none";
				var str="";
				str+='<div class="tbdc_title"><div class="tbdc_prevyear">&lt;&lt;</div><div class="tbdc_prevmonth">&lt;</div><div class="tbdc_month"></div><div class="tbdc_year"></div><div class="tbdc_nextmonth">&gt;</div><div class="tbdc_nextyear">&gt;&gt;</div></div>';
				str+='<div class="tbdc_week"><div>日</div><div>一</div><div>二</div><div>三</div><div>四</div><div>五</div><div>六</div></div>';
				str+='<div class="tbdc_con tbdc_clearfix"></div>';
				if(this.hm){
					str+='<div class="tbdc_hm"><p><span class="tbdc_hm_l">时间</span><span class="tbdc_hm_r"><em class="tbdc_hm_show">00:00</em></span></p><p><span class="tbdc_hm_l">小时</span><span class="tbdc_hm_r"><select class="tbdc_hm_h"><option selected>00</option><option>01</option><option>02</option><option>03</option><option>04</option><option>05</option><option>06</option><option>07</option><option>08</option><option>09</option><option>10</option><option>11</option><option>12</option><option>13</option><option>14</option><option>15</option><option>16</option><option>17</option><option>18</option><option>19</option><option>20</option><option>21</option><option>22</option><option>23</option></select></span></p><p><span class="tbdc_hm_l">分钟</span><span class="tbdc_hm_r"><select class="tbdc_hm_m"><option selected>00</option><option>01</option><option>02</option><option>03</option><option>04</option><option>05</option><option>06</option><option>07</option><option>08</option><option>09</option><option>10</option><option>11</option><option>12</option><option>13</option><option>14</option><option>15</option><option>16</option><option>17</option><option>18</option><option>19</option><option>20</option><option>21</option><option>22</option><option>23</option><option>24</option><option>25</option><option>26</option><option>27</option><option>28</option><option>29</option><option>30</option><option>31</option><option>32</option><option>33</option><option>34</option><option>35</option><option>36</option><option>37</option><option>38</option><option>39</option><option>40</option><option>41</option><option>42</option><option>43</option><option>44</option><option>45</option><option>46</option><option>47</option><option>48</option><option>49</option><option>50</option><option>51</option><option>52</option><option>53</option><option>54</option><option>55</option><option>56</option><option>57</option><option>58</option><option>59</option></select></span></p></div>';
				}else{};
				str+='<div class="tbdc_btns"><div class="tbdc_nowtime">当前时间</div><div class="tbdc_cleartime">清空</div></div>';
				if(this.speedmonth){
					str+='<div class="tbdc_speedm" style="display:none;"></div>';					
				};
				if(this.speedyear){
					str+='<div class="tbdc_speedy" style="display:none;"></div>';					
				};
				ddbox.innerHTML=str;
				this.obody.appendChild(ddbox);
			};
			//===================function===============================
			//快捷月份html处理
			this.speedmonthhtml=function(){
				this.speedm.innerHTML="";				
				for(var i=1;i<=12;i++){
					var sm=document.createElement("span");	
					var smm=this.twostr(this.toyear(this.dateObj));				
					if(i==smm){
						sm.className="tbdc_sel";
					}else{
						sm.className="";
					};
					sm.setAttribute('tm',i-1);
					sm.innerHTML=i+"月";
					this.speedm.appendChild(sm);
				};
			};
			//快捷年份html处理
			this.speedyearhtml=function(){
				this.speedy.innerHTML="";
				var year=parseInt(this.dateObj.getFullYear());		
				var interval=this.speedyear_interval;		
				for(var i=year-interval;i<=year+interval;i++){
					var sy=document.createElement("span");				
					if(i==year){
						sy.className="tbdc_sel";
					}else{
						sy.className="";
					};
					sy.setAttribute('ty',i);
					sy.innerHTML=i+"年";
					this.speedy.appendChild(sy);
				};
			};
			this.queryclass=function(root,classname){
				var list=root.getElementsByTagName("*");
				var earr=[];
				for(var i=0;i<list.length;i++){
					if(list[i].className.search(classname) != -1){
						earr.push(list[i]);
					};
				};
				return earr;
			};
			//有无指定类名的判断
			this.hasclass=function(str,cla){
				var i=str.search(cla);
				if(i==-1){
					return false;
				}else{
					return true;
				};
			};
			//有无指定类名的判断
			this.twostr=function(num){
				var res=(num.toString().length==1)?'0'+num:num;
				return res;
			};
			//初始化日期显示方法
			this.remove=function(){
				this.con.innerHTML="";
			};
			this.init=function(oneweek,alld,nowd){
				//当前时间对象信息
				oneweek=parseInt(oneweek);
				alld=parseInt(alld);
				nowd=parseInt(nowd);
				//上一个月时间对象信息总天数
				var palld=this.alldays(that.prevdateObj);
				//留空填充
				for(var i=1;i<=oneweek;i++){//留空
					var eday=document.createElement("div");
					eday.className="tbdc_eprev";
					if(that.isnull){
						eday.innerHTML="";
					}else{
						eday.innerHTML=palld-oneweek+i;
					};
					this.con.appendChild(eday);
				};
				//正常填充
				for(var i=1;i<=alld;i++){//正常区域
					var eday=document.createElement("div");
					if(i==nowd){
						eday.innerHTML=i;
						eday.className="tbdc_now tbdc_edate";
						this.con.appendChild(eday);
					}else{
						eday.innerHTML=i;
						eday.className="tbdc_edate";
						this.con.appendChild(eday);
					};
				};
				//计算剩余填充
				var after=((oneweek+alld)%7==0)?0:7-(oneweek+alld)%7;
				for(var i=1;i<=after;i++){//正常区域
					var eday=document.createElement("div");
					eday.className="tbdc_enext";
					if(that.isnull){
						eday.innerHTML="";
					}else{
						eday.innerHTML=i;
					};
					this.con.appendChild(eday);
				};
			};
			//获取本月1号的周值
			this.oneyearoneday=function(dateObj){
				var oneyear = new Date();
				var year=dateObj.getFullYear();
				var month=dateObj.getMonth();//0是12月
				oneyear.setFullYear(year);
				oneyear.setMonth(month);//0是12月
				oneyear.setDate(1);
				return oneyear.getDay();
			};
			//当前是几
			this.nowday=function(dateObj){
				return this.dateObj.getDate();
			};
			//获取本月总日数方法
			this.alldays=function(dateObj){
				var year=dateObj.getFullYear();
				var month=dateObj.getMonth();
				if(this.isLeapYear(year)){//闰年
					switch(month) {
					case 0:   return "31";   break;
					case 1:   return "29";   break;   //2月
					case 2:   return "31";   break;
					case 3:   return "30";   break;
					case 4:   return "31";   break;
					case 5:   return "30";   break;
					case 6:   return "31";   break;
					case 7:   return "31";   break;
					case 8:   return "30";   break;
					case 9:   return "31";   break;
					case 10:   return "30";   break;
					case 11:   return "31";   break;
					default:
					};
				}else{//平年
					switch(month) {
					case 0:   return "31";   break;
					case 1:   return "28";   break;  //2月
					case 2:   return "31";   break;
					case 3:   return "30";   break;
					case 4:   return "31";   break;
					case 5:   return "30";   break;
					case 6:   return "31";   break;
					case 7:   return "31";   break;
					case 8:   return "30";   break;
					case 9:   return "31";   break;
					case 10:   return "30";   break;
					case 11:   return "31";   break;
					default:
					};
				};
			};
			//闰年判断函数
			this.isLeapYear=function(year){
				if( (year % 4 == 0) && (year % 100 != 0 || year % 400 == 0)){
					return true;
				}else{
					return false;
				};
			};
			//月份转化方法
			this.toyear=function(dateObj){
				var month=dateObj.getMonth()
				switch(month) {
				case 0:   return "1";   break;
				case 1:   return "2";   break;
				case 2:   return "3";   break;
				case 3:   return "4";   break;
				case 4:   return "5";   break;
				case 5:   return "6";   break;
				case 6:   return "7";   break;
				case 7:   return "8";   break;
				case 8:   return "9";   break;
				case 9:   return "10";   break;
				case 10:   return "11";   break;
				case 11:   return "12";   break;
				default:
				};
			};
			//控制变化结构
			this.updatehtml=function(ddm,ddy,ddd){
				that.dateObj.setFullYear(ddy);
				that.dateObj.setMonth(ddm);
				that.dateObj.setDate(ddd);
				//前后时间对象设置
				that.setprevobj(that.dateObj);
				that.setnextobj(that.dateObj);
				//头部月日信息
				that.setyearmonth(that.dateObj);
				that.remove();
				var oneweek=that.oneyearoneday(that.dateObj);
				var alld=that.alldays(that.dateObj);
				var nowd=that.nowday(that.dateObj);
				that.init(oneweek,alld,nowd);
				//更新快捷月份指向
				if(this.speedmonth){
					this.speedmonthhtml();
				};
				//更新快捷年份指向
				if(this.speedyear){
					this.speedyearhtml();
				};
			};
			//月年显示方法
			this.setyearmonth=function(dateObj){
				that.omonth.innerHTML=that.toyear(dateObj)+"月";
				that.oyear.innerHTML=dateObj.getFullYear()+"年";
			};
			//点击获取选中效果
			this.sel=function(){
				var list=this.queryclass(this.con,"tbdc_edate");
				for(var i=0;i<list.length;i++){
					if((that.dateObj.getDate()-1)==i){
						list[i].className="tbdc_now tbdc_edate";
					}else{
						list[i].className="tbdc_edate";
					};
				};
			};
			//事件监听
			this.addevent=function(){
				//显示事件
				that.date.onfocus=function(event){//显示控件
					//隐藏其他显示快捷月份
					var lists=that.queryclass(document,"tbdc_speedm");
					for(var i=0;i<lists.length;i++){
						lists[i].style.display="none";
					};
					//隐藏其他显示快捷年份
					var listy=that.queryclass(document,"tbdc_speedy");
					for(var i=0;i<listy.length;i++){
						listy[i].style.display="none";
					};
					//隐藏其他显示控件
					listh=that.queryclass(document,"tbdc_box");
					for(var i=0;i<listh.length;i++){
						if(that.box!=listh[i]){;
							listh[i].style.display="none";
						};
					};
					//当前控件显示处理
					var s_top=document.documentElement.scrollTop || document.body.scrollTop;
					var s_left=document.documentElement.scrollLeft || document.body.scrollLeft;
					var datel=this.getBoundingClientRect().left+s_left+that.tl;
					var datet=this.getBoundingClientRect().top+s_top+that.tt;
					that.box.style.left=datel+"px";
					that.box.style.top=datet+"px";
					that.box.style.display="block";
				};
				//日期显示
				that.con.onclick=function(event){
					var ev=window.event || event;
					var target= ev.srcElement || ev.target;
					if(target.nodeType=="1"){
						if(that.hasclass(target.className,"tbdc_edate")){
							if(that.hm){
								that.date.value="";
								that.date.value=that.dateObj.getFullYear()+that.splits+that.twostr(that.toyear(that.dateObj))+that.splits+that.twostr(target.innerHTML)+" "+that.stime.innerHTML;
							}else{
								that.date.value="";
								that.date.value=that.dateObj.getFullYear()+that.splits+that.twostr(that.toyear(that.dateObj))+that.splits+that.twostr(target.innerHTML);
							};														
							//修改事件对象日为当前值
							that.dateObj.setDate(target.innerHTML);
							that.sel();
						}else if(that.hasclass(target.className,"tbdc_eprev")){
							if(!that.isnull){
								if(that.hm){
									that.date.value="";
									that.date.value=that.prevdateObj.getFullYear()+that.splits+that.twostr(that.toyear(that.prevdateObj))+that.splits+that.twostr(target.innerHTML)+" "+that.stime.innerHTML;
								}else{
									that.date.value="";
									that.date.value=that.prevdateObj.getFullYear()+that.splits+that.twostr(that.toyear(that.prevdateObj))+that.splits+that.twostr(target.innerHTML);
								};
								var ddm=null;
								var ddy=null;
								if((that.dateObj.getMonth()-1)==-1){
									ddm=11;
									ddy=that.dateObj.getFullYear()-1;
								}else{
									ddm=that.dateObj.getMonth()-1;
									ddy=that.dateObj.getFullYear();
								};
								var ddd=target.innerHTML;
								that.updatehtml(ddm,ddy,ddd);
							};
						}else if(that.hasclass(target.className,"tbdc_enext")){
							if(!that.isnull){
								if(that.hm){
									that.date.value="";
									that.date.value=that.nextdateObj.getFullYear()+that.splits+that.twostr(that.toyear(that.nextdateObj))+that.splits+that.twostr(target.innerHTML)+" "+that.stime.innerHTML;
								}else{
									that.date.value="";
									that.date.value=that.nextdateObj.getFullYear()+that.splits+that.twostr(that.toyear(that.nextdateObj))+that.splits+that.twostr(target.innerHTML);
								};
								var ddm=null;
								var ddy=null;
								if((that.dateObj.getMonth()+1)==12){
									ddm=0;
									ddy=that.dateObj.getFullYear()+1;
								}else{
									ddm=that.dateObj.getMonth()+1;
									ddy=that.dateObj.getFullYear();
								};
								var ddd=target.innerHTML;
								that.updatehtml(ddm,ddy,ddd);
							};
						};
						if(that.clickhide){
							that.box.style.display="none";
						}else{
								
						};
					};
				};
				//清空
				that.cleartime.onclick=function(event){
					that.date.value="";
					if(that.clickhide){
							that.box.style.display="none";
					}else{
								
					};
				};
				//点击隐藏
				document.documentElement.onclick=function(){
					var listh=that.queryclass(document,"tbdc_box");
					for(var i=0;i<listh.length;i++){
						listh[i].style.display="none";
					};
					var lists=that.queryclass(document,"tbdc_speedm");
					for(var i=0;i<lists.length;i++){
						lists[i].style.display="none";
					};
					var listy=that.queryclass(document,"tbdc_speedy");
					for(var i=0;i<listy.length;i++){
						listy[i].style.display="none";
					};
				};
				//阻止冒泡
				that.box.onclick=function(event){
					if(that.speedmonth){
						that.speedm.style.display="none";
					};
					if(that.speedyear){
						that.speedy.style.display="none";
					};					
					if (event && event.stopPropagation){
						event.stopPropagation();
					}else{
						window.event.cancelBubble = true;
					};
				};
				that.date.onclick=function(event){
					if (event && event.stopPropagation){
						event.stopPropagation();
					}else{
						window.event.cancelBubble = true;
					};
				};
				//取消双击选中
				that.box.onselectstart=function(event){
					return false;
				};
				//上下控制
				that.prevmonth.onclick=function(){//上一月
					var ddm=null;
					var ddy=null;
					if((that.dateObj.getMonth()-1)==-1){
						ddm=11;
						ddy=that.dateObj.getFullYear()-1;
					}else{
						ddm=that.dateObj.getMonth()-1;
						ddy=that.dateObj.getFullYear();
					};
					var ddd=that.dateObj.getDate();
					that.updatehtml(ddm,ddy,ddd);
				};
				that.nextmonth.onclick=function(){//下一月
					var ddm=null;
					var ddy=null;
					if((that.dateObj.getMonth()+1)==12){
						ddm=0;
						ddy=that.dateObj.getFullYear()+1;
					}else{
						ddm=that.dateObj.getMonth()+1;
						ddy=that.dateObj.getFullYear();
					};
					var ddd=that.dateObj.getDate();
					that.updatehtml(ddm,ddy,ddd);
				};
				that.prevyear.onclick=function(){//上一年
					var ddy=that.dateObj.getFullYear()-1;
					var ddm=that.dateObj.getMonth();
					var ddd=that.dateObj.getDate();
					that.updatehtml(ddm,ddy,ddd);
				};
				that.nextyear.onclick=function(){//下一年
					var ddy=that.dateObj.getFullYear()+1;
					var ddm=that.dateObj.getMonth();
					var ddd=that.dateObj.getDate();
					that.updatehtml(ddm,ddy,ddd);
				};
				//返回到今时今日
				that.nowtime.onclick=function(){
					var dddate=new Date();
					var ddm=dddate.getMonth();
					var ddy=dddate.getFullYear();
					var ddd=dddate.getDate();
					that.updatehtml(ddm,ddy,ddd);
					if(that.hm){
						var ihm=new Date();
						var ih=that.twostr(ihm.getHours());
						var im=that.twostr(ihm.getMinutes());
						that.stime.innerHTML=ih+":"+im;
						that.date.value="";
						that.date.value=that.dateObj.getFullYear()+that.splits+that.twostr(that.toyear(that.dateObj))+that.splits+that.twostr(that.dateObj.getDate())+" "+ih+":"+im;
					}else{
						that.date.value="";
						that.date.value=that.dateObj.getFullYear()+that.splits+that.twostr(that.toyear(that.dateObj))+that.splits+that.twostr(that.dateObj.getDate());
					};
					if(that.clickhide){
							that.box.style.display="none";
					}else{
								
					};
				};
				//时分设置
				if(that.hm){
					that.htime.onchange=function(){
						that.stime.innerHTML=that.htime.value+":"+that.mtime.value;
						that.date.value="";
						that.date.value=that.dateObj.getFullYear()+that.splits+that.twostr(that.toyear(that.dateObj))+that.splits+that.twostr(that.dateObj.getDate())+" "+that.stime.innerHTML;
					};
					that.mtime.onchange=function(){
						that.stime.innerHTML=that.htime.value+":"+that.mtime.value;
						that.date.value="";
						that.date.value=that.dateObj.getFullYear()+that.splits+that.twostr(that.toyear(that.dateObj))+that.splits+that.twostr(that.dateObj.getDate())+" "+that.stime.innerHTML;
					};
				};
				//快接月份处理
				if(this.speedmonth){
					that.omonth.onclick=function(event){
						that.speedm.style.display="block";
						if (event && event.stopPropagation){
							event.stopPropagation();
						}else{
							window.event.cancelBubble = true;
						};
					};
					that.speedm.onclick=function(event){
						var ev=window.event || event;
						var target= ev.srcElement || ev.target;
						if(target.nodeType=="1"){
							if(target.getAttribute("tm")){
								var ddm=target.getAttribute("tm");
								var ddy=that.dateObj.getFullYear();
								var ddd=that.dateObj.getDate();
								that.updatehtml(ddm,ddy,ddd);
								that.speedm.style.display="none";
							}else{};
						}else{};
						if (event && event.stopPropagation){
							event.stopPropagation();
						}else{
							window.event.cancelBubble = true;
						};
					};			
				};	
				//快接年份处理
				if(this.speedyear){
					that.oyear.onclick=function(event){
						that.speedy.style.display="block";
						if (event && event.stopPropagation){
							event.stopPropagation();
						}else{
							window.event.cancelBubble = true;
						};
					};	
					that.speedy.onclick=function(event){
						var ev=window.event || event;
						var target= ev.srcElement || ev.target;
						if(target.nodeType=="1"){
							if(target.getAttribute("ty")){
								var ddm=that.dateObj.getMonth();
								var ddy=target.getAttribute("ty");
								var ddd=that.dateObj.getDate();
								that.updatehtml(ddm,ddy,ddd);
								that.speedy.style.display="none";
							}else{};
						}else{};
						if (event && event.stopPropagation){
							event.stopPropagation();
						}else{
							window.event.cancelBubble = true;
						};
					};			
				};																		
			};
		};
		//new obj
		return new TBDcalendar(id,opts).open();
	};
	//global
	w.Tbdcalendar=Tbdcalendar;
})(window);
